Skip to content

fix(daemon): point a --device UDID conflict to --udid - #4004

Merged
thymikee merged 2 commits into
callstack:mainfrom
zerone0x:fix/session-device-udid-selector
Oct 29, 2026
Merged

thymikee merged 2 commits into
callstack:mainfrom
zerone0x:fix/session-device-udid-selector

Conversation

@zerone0x

@zerone0x zerone0x commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A session bound to an Apple device rejects --device=<UDID> of that same device with INVALID_ARGS. As decided on #3945, --device stays a name selector and --udid the ID selector, so the rejection is kept. The error now tells the caller which flag takes that value.

  • listSessionSelectorConflicts is unchanged: --device still matches only the device name.
  • New describeDeviceUdidSelectorConflict: when a --device conflict's value equals the bound Apple device's UDID, the conflict message adds --device selects a device by name; select this device by UDID with --udid <UDID>. Used by assertSessionSelectorMatches and by the bound-session request-lock conflict message.
  • A different UDID, or an Android serial passed as --device, gets the plain conflict error with no --udid pointer.
  • No resolveCommandDevice change.

Refs #3945

Validation

  • vitest run on session-selector.test.ts, session-device-resolution.test.ts, request-lock-policy.test.ts: 48 passed.
  • oxfmt --check on the touched TS files: pass.
  • tsc -b packages/daemon: pass.
  • Not run locally: check:affected, oxlint. CI is the authority for these.

🤖 Generated with Claude Code

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

At 8253d3d, the issue's own scenario works from reading the code: the bound UDID is accepted as --device and a different device is rejected. I did not run the added tests or the revert check, and I did not run a provider-scoped request with a bound UDID, so that route is still unconfirmed. The one check reported is green, and I know of no conflicts.

Not blocking, take or leave: (1) The rewrite lives only in resolveCommandDevice (request-platform-provider-context.ts#L86), so for a bound session with preferExplicitDeviceOverExistingSession, resolveProviderTargetDevice still passes the raw --device=<UDID>, gets DEVICE_NOT_FOUND, and the catch turns it into no provider scope. The request then resolves in the handler but gets no provider context. The rule should hold once where the request is checked against the session, so every re-resolution sees it. (2) isBoundAppleDeviceUdid (session-selector.ts#L108) repeats the --udid predicate three lines above it. deviceIdentityFlag(platform) in kernel already maps Apple to udid and Android to serial, so Android serials and the macOS exclusion should follow that one rule, or the PR should say why they stay out. (3) Kernel documents --device as a name and hints Did you mean --udid for an identity (device.ts#L616), yet a bound session now accepts the same value. If that split stays, the --device help text should say so. I did not check generated CLI help or the website docs for the --device wording.

Could one normalization step cover all of this? Where the request is bound to the session (around request-execution-scope.ts line 731, before handlers and provider context), if flags.device equals the bound device id, replace it with the platform's identity flag from deviceIdentityFlag. Then the session check and every resolver see a normal --udid, listSessionSelectorConflicts needs no change, and the new helper goes away. The alternative is an exact-id fallback in kernel resolveDeviceByName. Before either, we would need to decide whether --device may carry an identity at all.

Before merge, please run a provider-scoped request on a bound session with --device=<UDID> and show that it reaches the provider context. Please also confirm the added tests pass and fail when the change is reverted.

@thymikee

Copy link
Copy Markdown
Member

Thanks for picking this up. We decided on #3945 to keep --device as a name selector and --udid as the ID selector, rather than letting --device accept a UDID. Could you change this PR to keep the rejection, and make the conflict error point to --udid <UDID> when the value matches the bound device's UDID? Then the resolveCommandDevice change is not needed.

Per review on callstack#3945, --device stays a name selector and --udid the ID
selector. Keep rejecting --device=<UDID> for a session bound to an Apple
device, but when the value is the bound device's UDID, the conflict error
now says to use --udid <UDID>. Drop the resolveCommandDevice change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zerone0x zerone0x changed the title fix(daemon): accept the bound Apple device UDID as --device fix(daemon): point a --device UDID conflict to --udid Oct 28, 2026
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

@zerone0x is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@zerone0x

Copy link
Copy Markdown
Contributor Author

Thanks, done in 417cfb5.

  • --device matches only the device name again, so --device=<UDID> is still rejected.
  • When the value is the bound Apple device's UDID, the conflict error now ends with --device selects a device by name; select this device by UDID with --udid <UDID>. Both assertSessionSelectorMatches and the session-lock conflict message add it.
  • A different UDID, or an Android serial given as --device, gets the plain conflict error.
  • Dropped the resolveCommandDevice change.

I also changed Fixes #3945 to Refs #3945, since this no longer makes --device accept a UDID. Happy to switch it back if you'd like this to close the issue.

@thymikee

Copy link
Copy Markdown
Member

The code looks good at 417cfb5, and it addresses the points from the earlier review at 8253d3d (#4004 (comment)). Not blocking, and fine to take or leave: describeDeviceUdidSelectorConflict in https://github.com/callstack/agent-device/blob/417cfb5/packages/daemon/src/core/session-selector.ts#L108 repeats the rule that deviceIdentityMistakenForNameHint in packages/kernel/src/device.ts already applies, with its own wording and an inline --udid literal, so a bound session and an unbound request get different text for the same mistake. You can export the kernel hint builder and use it at both sites, or leave it and align the wording. The only check that is not passing is Vercel, and its link is a fork authorization URL, not a build error. The diff does not touch the website it deploys, so this is likely unrelated. There are no conflicts. I did not run the tests, the revert check, oxlint or check:affected, and the PR body says the last two were not run locally. Before merge, check:affected and oxlint need to pass on this head. I also did not check the generated CLI help or website docs for the --device wording.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 28, 2026
@thymikee
thymikee merged commit a957bf5 into callstack:main Oct 29, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants